import pymysql

# 1.连接MySQL
conn = pymysql.connect(host="127.0.0.1", port=3306, user="root", password="123456", charset="utf8mb4", db="zzm")
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)

cursor.execute("select * from admin where id > %s", [3, ])
data_list = cursor.fetchall()  # fetchall()获取符合条件的所有数据，fetchone()获取符合条件的第一条数据
for row_dict in data_list:
    print(row_dict)

# 3.关闭
cursor.close()
conn.close()
# 在进行新增，删除，修改时，一定要记得commit，不然数据库没有数据
# cursor.execute("...")
# conn.commit()
